package com.pioneer.admin.controller.book;

import com.pioneer.common.annotation.Log;
import com.pioneer.common.constant.BookConstants;
import com.pioneer.common.core.controller.BaseController;
import com.pioneer.common.core.domain.AjaxResult;
import com.pioneer.common.enums.BusinessType;
import com.pioneer.common.utils.SecurityUtils;
import com.pioneer.web.book.domain.BorrowRecord;
import com.pioneer.web.book.service.IBorrowRecordService;
import jakarta.annotation.Resource;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.web.bind.annotation.*;

import java.util.Arrays;
import java.util.List;

/**
 * 记录
 *
 * @author xx
 */
@RestController
@RequestMapping("/borrow/mybook")
public class MyBookController extends BaseController {

    @Resource
    private IBorrowRecordService borrowRecordService;

    /**
     * 获取该用户借阅列表
     *
     * @return 结果
     */
    @PreAuthorize("@ss.hasPerm('borrow:mybook:list')")
    @GetMapping("/list")
    public AjaxResult myBook() {
        boolean isPage = startPage();
        List<BorrowRecord> list = borrowRecordService.selectRecordByUserID(SecurityUtils.getLoginUser().getUserId(), BookConstants.BOOK_STATUS_NOT_RETURN);
        return success(isPage, list);
    }
}
